home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / linuxcon.000 / linuxcon / linuxconf-1.6 / misc / malloc.c < prev    next >
C/C++ Source or Header  |  1996-03-02  |  586b  |  32 lines

  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <unistd.h>
  4. #include "misc.h"
  5. #include "../xconf/xconf.h"
  6. #include "misc.m"
  7.  
  8. /*
  9.     Do a malloc with error message generation. It quit if out of memory.
  10. */
  11. void *malloc_err (int size)
  12. {
  13.     void *ret = malloc(size);
  14.     if (ret == NULL){
  15.         xconf_error (MSG_U(E_OUTOFMEM,"Out of memory\n"));
  16.         exit (-1);
  17.     }
  18.     return ret;
  19. }
  20.  
  21. /*
  22.     Do a strdup with error message generation. It quit if out of memory.
  23. */
  24. char *strdup_err (const char *str)
  25. {
  26.     char *ret = strdup (str);
  27.     if (ret == NULL){
  28.         xconf_error (MSG_R(E_OUTOFMEM));
  29.         exit (-1);
  30.     }
  31.     return ret;
  32. }